
import copy
aborad = [[0 for j in range(10)] for i in range(10)]
count = [[0 for j in range(10)] for i in range(10)]

ashiplist = ["DD","SSS","CCC","BBBB","AAAAA"]

def clcount(preshiplist,preborad):
    print("\nthe shiplist is :",preshiplist)
    shiplist=copy.deepcopy(preshiplist)
    borad = copy.deepcopy(preborad)
    if shiplist==None or shiplist==[]:
        return 
    for ship in shiplist:
        for i in range(10):
            for j in range(10):
                if borad[i][j]!=0:
                    continue
                else:
                    ship_len = len(ship)
                    boradx=copy.deepcopy(borad)
                    if j+ship_len-1 <=9: #x方向边界检测
                        fang=True
                        for l in range(ship_len):
                            if boradx[i][j+l]!=0:
                                fang=False
                        if fang:
                            
                            for l in range(ship_len): #将所在位置置为1
                                boradx[i][j+l] = list(ship)[0]
                                count[i][j+l]+=1
                            nextshiplist = copy.deepcopy(shiplist)
                            nextshiplist.remove(ship)
                            clcount(nextshiplist,boradx)
                    borady=copy.deepcopy(borad)
                    if i+ship_len-1<=9:   #y方向边界检测
                        fang=True
                        for l in range(ship_len):
                            if borady[i+l][j]!=0:
                                fang=False

                        if fang:
                            
                            for l in range(ship_len): #将所在位置置为1
                                borady[i+l][j] = list(ship)[0]
                                count[i+l][j] += 1
                            nextshiplisty = copy.deepcopy(shiplist)
                            nextshiplisty.remove(ship)
                            clcount(nextshiplisty,borady)
    return

clcount(ashiplist,aborad)

print(count)
    